<?php

$Datas = @implode( '', file( 'http://keyword.discuz.com/related_kw.html?title='.rawurlencode( strip_tags( $_GET['title'] ) ).'&content='.rawurlencode( strip_tags( $_GET['text'] ) ).'&ics=utf-8&ocs=utf-8' ) );

$Keywords = array( );
if ( $Datas ) {
	$XmlParser = xml_parser_create( );
	xml_parser_set_option( $XmlParser, XML_OPTION_CASE_FOLDING, 0 );
	xml_parser_set_option( $XmlParser, XML_OPTION_SKIP_WHITE, 1 );
	xml_parse_into_struct( $XmlParser, $Datas, $DataArray, $Index );
	xml_parser_free( $XmlParser );

	foreach ( $DataArray as $array ) {
		if ( $array['tag'] == 'kw' || $array['tag'] == 'ekw') {
			$Keywords[] = htmlspecialchars( trim( $array['value'] ) );
		}
	}
}

echo implode( ' ', $Keywords );
